module ICarry {

        export class ICarryContext {

        private _app: ICarryApplication;
        private CurrentStep: Step;
        private StepHistory: Step[];

        constructor(app: ICarryApplication) {
            this._app = app;
            this.StepHistory = [];
        }

        public SetCurrentStep(step: Step, deleting?:boolean): void {

            this.CurrentStep = step;
            this.StepHistory.push(step);

            
        }

        public GetCurrentStep(): Step {

            return this.CurrentStep;
        }

        public GetPreviousStep(hop?: number): Step {

            var hop = hop;

            if (!hop || hop < 0) {
                hop = 1;
            }

            var previousStep = this.StepHistory[this.StepHistory.length - 1 - hop];

            if (previousStep) {
                return previousStep;
            }
            else {
                return null;
            }
        }

        public GetNextStep(hop?: number): Step {

            var hop = hop;

            if (!hop || this.StepHistory.length - 1 < this.StepHistory.indexOf(this.CurrentStep) + hop) {
                hop = 1;
            }

            var nextStep = this.StepHistory[this.StepHistory.length - 1 + hop];

            if (nextStep) {
                return nextStep;
            }
            else {
                return null;
            }
        }

    }

    export enum Step {
        Intro,
        RequestOffer,
        UserSelection

    }
}